/*
 * MetaDataLoader.h
 *
 *  Created on: Nov 3, 2011
 *      Author: gassa
 */

#ifndef METADATALOADER_H_
#define METADATALOADER_H_

#include <map>
#include <string>
#include <iostream>
#include "../include/config.h"
#include "Term.h"

class MetaDataLoader {
private:
	static bool instanceFlag;
	static MetaDataLoader* instance;
	config *configInstance;
	int barrelNumber;
	map<char, int> barrelMapper;
	MetaDataLoader();
public:
	virtual ~MetaDataLoader();
	map< string, Term> authorMapper;
	map<string, Term> categotyMapper;
	vector<map<size_t, size_t>*> authorToPlMapping;
	vector<map<size_t, size_t>*> categoryToPlMapping;

	static MetaDataLoader* getInstance();
	void setBarrelNumberToMap();
	void loadAuthorDict();
	void loadAuthorIndex();
	void loadCategoryDict();
	void loadCategoryIndex();
	Term* loadAuthorPostingList(string termString);
	Term* loadCategoryPostingList(string termString);
	string readPostinglistByOffset(int barrelNumber, int offset, string dirString);
	void postingListStringToObject(Term& t);
};
#endif /* METADATALOADER_H_ */
